﻿@model PagedList.IPagedList<VOD.Models.Video>
@using VOD.Helpers;
@{
    ViewBag.Title = Request.QueryString["videoName"]+" - 搜索结果";
    Layout = "~/Views/Shared/Templates/_PageLayout.cshtml";
    var page=Convert.ToInt32(ViewBag.Page);
    int pagesCount=7;
    if(Model.PageCount-2<pagesCount)
    {
        pagesCount = Model.PageCount - 2;
    }
    int start;
    int end;
}
<div class="channel clearfix">
    <div class="left">
        <div id="phb">
            <div class="top">周排行榜</div>
            <div class="content">
                @*周排行列表*@
                @{Html.RenderAction("TopRank", "Video");}
            </div>
        </div>
    </div>
    <div class="right">
        <div class="crumb"><a href="@Url.Content("~/Home/Index")">首页</a>&nbsp;&gt;&nbsp; 搜索 </div>
        <div class="searchCondition">
            <div class="level_1">
                <p class="">搜索<span>"@Request.QueryString["VideoName"]"</span>共<span>@Model.Count()</span>项视频结果</p>
            </div>
        </div>
        <div class="orderBox">
            <dl>
                <dt>排序方式：</dt>
                <dd>
                    <a href="/s_video/q_%E8%B5%A4%E8%A3%B8_sort_0" title="热度">热度</a>
                    <a href="/s_video/q_%E8%B5%A4%E8%A3%B8_sort_1" title="更新">更新</a>
                    <a href="/s_video/q_%E8%B5%A4%E8%A3%B8_sort_3" title="评分">评分</a>
                </dd>
            </dl>
        </div>
        @foreach (var video in Model)
        {
            <div class="searchVideo1 clearfix">
                <a target="_blank" class="showImg" title="@video.Name" href="@Url.Action("Play", "Video", new { id = video.VideoID })">
                    <img width="92" height="128" alt="@video.Name" src="@Url.Content("~/Content/images/videoimg/" + video.VideoID + ".jpg")" onerror="javascript:this.src='@Url.Content("~/Content/images/nopic.jpg")'">
                </a>
                <div class="showInfo">
                    <dl>
                        <dt class="info1">
                            <a target="_play" title="@video.Name" href="@Url.Action("Play", "Video", new { id = video.VideoID })">@video.Name</a>
                        </dt>
                        <dd class="info2">
                            演员：@video.Actor<br>
                            导演：@video.Director<br>
                            类型：@foreach (var type in video.VideoAndTypes)
                               { 
                                @type.VideoType.TypeName@:&nbsp;
                               }<br>
                            年份：@video.ShowYear<br>
                            简介：@Html.Truncate(video.Intro, 100)
                        </dd>
                    </dl>
                </div>
            </div>
        }
        <div class="newNum">
            <p class="info_1">共有@(Model.Count)部</p>
            <p class="info_2">
                @if (!Model.IsFirstPage)
                { 
                    <strong>@Html.ActionLink("上一页", "Index", "Search",new { page = Model.PageIndex, videoName = Request.QueryString["videoName"] }, new { @class = "next"})</strong>
                }
                
                @for (var i = 1; i <= Model.PageCount; i++)
                {
                     @Html.ActionLink(i.ToString(), "Index", "Search", new { videoName = Request.QueryString["videoName"], page = i }, new { @class = "next" })
                }
                
                @*@Html.ActionLink("1", "Index", "Search", new { videoName = Request.QueryString["videoName"], page = 1 }, new { @class = "next" })
                @if (Model.PageCount - 2 >= pagesCount)
                {
                     <span href="javascript:;" class="n">...</span>
                }
                @{
                    if(Model.PageNumber-4<=1)
                    {
                        start = 2;
                    }
                    else
                    {
                        start = Model.PageNumber - 3;
                    }
                    end=pagesCount+1;
                    for (var i=start; i<=end;i++ )
                    {
                        @Html.ActionLink(i.ToString(), "Index", "Search", new { videoName = Request.QueryString["videoName"], page = i }, new { @class = "next" })
                    }
                }

                @if (Model.PageCount - 2 > pagesCount)
                {
                     <span href="javascript:;" class="n">...</span>
                }
                @if (Model.Count > 2)
                {
                    @Html.ActionLink(Model.Count.ToString(), "Index", "Search", new { videoName = Request.QueryString["videoName"], page = Model.Count }, new { @class = "next" }) 
                }*@
                
                @if (!Model.IsLastPage)
                {
                    <strong>@Html.ActionLink("下一页", "Index", "Search", new { page = Model.PageIndex + 2, videoName = Request.QueryString["videoName"] }, new { @class = "next" })</strong>
                }
            </p>
        </div>
    </div>
</div>